package javacompiler.codegenerator;

import java.util.ArrayList;
import java.util.List;

public class Instruction {

	public enum AssemblyOperator {
		ADD("ADD"), SUB("SUB"), MUL("MUL"), DIV("DIV"), LOAD("LD"), MOVE("MOV"),
		BRANCH("BR"), BLTZ("BLTZ"), BRZ("BRZ"), BGTZ("BGTZ"), STORE("ST"), BLANK("");
		
		private String code;
		
		private AssemblyOperator(String code) {
			this.code = code;
		}
		
		public String toCode() {
			return code;
		}
	}

	private AssemblyOperator operator;
	private List<Register> registers;
	private List<Double> constants;
	private String variableName;
	private List<Long> addresses;
	private Long memoryAddress;
	private String label;
	
	public Instruction() {
		registers = new ArrayList<Register>();
		constants = new ArrayList<Double>();
		addresses = new ArrayList<Long>();
		memoryAddress = -1L;
	}
	
	public Instruction(AssemblyOperator operator, List<Register> registers,
			List<Double> constants, String variableName, List<Long> addresses) {
		this.operator = operator;
		this.registers = registers;
		this.constants = constants;
		this.variableName = variableName;
		this.addresses = addresses;
		memoryAddress = -1L;
	}
	
	public AssemblyOperator getOperator() {
		return operator;
	}
	
	public void setOperator(AssemblyOperator operator) {
		this.operator = operator;
	}
	
	public List<Register> getRegisters() {
		return registers;
	}
	
	public void setRegisters(List<Register> registers) {
		this.registers = registers;
	}
	
	public void addRegister(Register register) {
		registers.add(register);
	}
	
	public List<Double> getConstants() {
		return constants;
	}
	
	public void setConstants(List<Double> constants) {
		this.constants = constants;
	}	
	
	public void addConstant(Double constant) {
		constants.add(constant);
	}

	public String getVariableName() {
		return variableName;
	}

	public void setVariableName(String variableName) {
		this.variableName = variableName;
	}

	public List<Long> getAddresses() {
		return addresses;
	}

	public void setAddresses(List<Long> addresses) {
		this.addresses = addresses;
	}
	
	public void addAddress(Long address) {
		addresses.add(address);
	}

	public Long getMemoryAddress() {
		return memoryAddress;
	}

	public void setMemoryAddress(Long memoryAddress) {
		this.memoryAddress = memoryAddress;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}
}
